package com.example.musicplayer.utils;

import java.util.ArrayList;

import com.example.musicplayer.MusicPlaybackActivity;
import com.example.musicplayer.bean.Music;
import com.example.musicplayer.common.MusicConstant;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class UIHelper {

    public static void viewAndPlayMusic(Context context, Uri data) {
        viewAndPlayMusic(context, data, null);
    }

    public static void viewAndPlayMusic(Context context, Uri data, String songName) {
        Intent intent = new Intent(context, MusicPlaybackActivity.class);

        intent.setData(data);
        intent.putExtra(MusicConstant.EXTRA_SONG_NAME, songName);

        context.startActivity(intent);
    }

    public static void viewAndPlayMusic(Context context, ArrayList<Music> musics, int curPosition) {
        Intent intent = new Intent(context, MusicPlaybackActivity.class);
        intent.putParcelableArrayListExtra(MusicConstant.EXTRA_SONG_LIST, musics);
        intent.putExtra(MusicConstant.EXTRA_SONG_POSITION, curPosition);

        context.startActivity(intent);
    }
}
